<?php

class View {

	private $title;

	private $css;

	private $javascript;

	protected $display;

	public function template($page) {
		$page = VIEW . '/' . $page . EXT;

		require_once $page;
	}

	public function setDisplay($key, $data) {
		$this->display[$key] = $data;
	}

	public function setCss($css) {
		$this->css[] = $css;
	}

	public function setJavascript($js) {
		$this->javascript[] = $js;
	}

	public function setTitle($title) {
		$this->title = $title;
	}

	protected function getCss() {
		return $this->addCss($this->css);
	}

	public function getJavascript() {
		return $this->addJs($this->javascript);
	}

	public function getTitle() {
		return $this->title;
	}

	public function addCss($css) {
		$cssFiles = '';

		if (is_array($css)) {
			foreach ($css AS $file) {
				$cssFiles .= '<link rel="stylesheet" type="text/css" href="' . TemplateHelper::getCssUrl() . $file . '.css " media="screen" />' . "\n";
			}
		}

		return $cssFiles;
	}

	public function addJs($js) {
		$jsFiles = '';

		if (is_array($js)) {
			foreach ($js AS $file) {
				$jsFiles .= '<script src="' . TemplateHelper::getJsUrl() . $file .'.js"></script>' . "\n";
			}
		}

		return $jsFiles;
	}
}